import request from "@/request/";

export const getDataList = (url, method, data = {}, urlConfig = {}) => {
  if (method == "get") {
    return request({
      url,
      method,
      params: data,
      isShowLoading:
        urlConfig.isShowLoading !== undefined ? urlConfig.isShowLoading : false,
    });
  } else if (method == "post") {
    return request({
      url,
      method,
      data,
      isShowLoading:
        urlConfig.isShowLoading !== undefined ? urlConfig.isShowLoading : false,
    });
  }
};

export const getCommonEnum = (url, keyList) => {
  return request({
    url: `/api/${url}/preset/enum/list`,
    method: "POST",
    data: {
      keyList,
    },
  });
};

// 导入模板下载
export const downLoadTemplate = (data) => {
  return request({
    url: `/api/mes-warehouse-service/preset/template/upload`,
    method: "POST",
    responseType: "blob",
    timeout: 300000,
    data: data,
  });
};

// 统一导出
export const exportFile = (code, params) => {
  return request({
    url: "/api/trio-system/async/record/export",
    method: "post",
    data: {
      bizMouldCode: code,
      paramsMap: params,
    },
  });
};

export const exportFileById = (exportRecordId) => {
  return request({
    url: "/api/trio-system/async/record/export-record/download",
    method: "post",
    responseType: "blob",
    data: {
      exportRecordId,
    },
  });
};
